
#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QGraphicsPixmapItem>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QMediaPlayer>//音乐
#include <QList>//链表
#include <QTimer>//定时器
#include "movedirection.h"
#include <QPushButton>
#include <QToolButton>
#include <QPainter>
#include "text.h"
#include <QLabel>
#include <QMovie>
#include <QToolButton>
#include <QtMultimediaWidgets/QVideoWidget>
#include <QtMultimedia/QMediaPlayer>
#include <QGraphicsProxyWidget>
#include <QGraphicsVideoItem>
#include <QPropertyAnimation>


QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget

{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);

    //游戏主页面
    void BeforeAll();
    void StartGame();
    void SongOver();
    void HPOver();


    //按键事件
    void keyPressEvent(QKeyEvent* event);
    void keyReleaseEvent(QKeyEvent* event);

    //分数
    QGraphicsTextItem *mPoint;

    //碰撞函数
    void collision();//碰撞

    //播放CG动画
    void playCG();
    void startCG();
    ~Widget();

    //text**********************************************************************************************************************
    void InitByFile(QString fileName);

    void clear();

    //QWidget* widget;

    int length;
    int col;
    int** map;
    int time;
    int TimeLevel;
    int i;
    int score;
    float volume;// 音量
    bool bt;//按钮是否可按
    float Opacity;//透明度

private:
    Ui::Widget *ui;


    //场景视图
    QGraphicsView mGameView;
    QGraphicsScene mScene;
    QGraphicsScene STARTScene;
    QGraphicsPixmapItem up;
    QGraphicsPixmapItem left;
    QGraphicsPixmapItem right;
    QGraphicsPixmapItem down;
    QGraphicsPixmapItem up_check;
    QGraphicsPixmapItem left_check;
    QGraphicsPixmapItem right_check;
    QGraphicsPixmapItem down_check;
    QGraphicsPixmapItem background;
    QGraphicsPixmapItem startbackground;
    QGraphicsPixmapItem otto;
    QGraphicsPixmapItem title;
    QGraphicsPixmapItem oversong;

    //音乐
    QMediaPlayer BGM;
    QMediaPlayer STARTBGM;
    QMediaPlayer SE;

    //定时器
    QTimer* DirectPointTimer;//按键变形
    QTimer* DirectMoveTimer;//箭头移动定时器
    QTimer* TimeTimer1;
    QTimer* TimeTimer2;
    QTimer* TimeTimer3;
    QTimer* TimeTimer4;//歌曲时长计时器
    QTimer* startTimer;
    QTimer* musicoverTimer;
    QTimer* pictureTimer;

    //容器
    QList<int> KeyList;//按键组合
    QList<MoveDirection*>UPsList;
    QList<MoveDirection*>LEFTsList;
    QList<MoveDirection*>DOWNsList;
    QList<MoveDirection*>RIGHTsList;//箭头容器

    //箭头函数
    void DirectChange();//变色

    //谱面
    text* TEXT;

    //CG播放器
    QMediaPlayer *player;
    QVideoWidget* videoWidget;
    QGraphicsProxyWidget* videoProxy;

private slots:
    //方向生成函数
    void MakeDirectionUP();
    void MakeDirectionLEFT();
    void MakeDirectionDOWN();
    void MakeDirectionRIGHT();
    void paint0();
    void paint1();
    void paint2();
    void paint3();
    void paint4();

    void showpoint();

};

#endif // WIDGET_H
